package com.wbdgj.ui.booking;

import android.Manifest;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;

import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.bumptech.glide.Glide;
import com.google.gson.internal.LinkedTreeMap;
import com.igexin.sdk.PushManager;
import com.wbdgj.R;
import com.wbdgj.base.BaseActivity;
import com.wbdgj.base.BaseApplication;
import com.wbdgj.http.HttpAdapter;
import com.wbdgj.http.OnNoResponseListener;
import com.wbdgj.http.OnResponseListener;
import com.wbdgj.model.ResultObjectModel;
import com.wbdgj.ui.login.LoginActivity;
import com.wbdgj.utils.ContextUtils;
import com.wbdgj.utils.SpKeyUtils;
import com.wbdgj.utils.ToastUtils;
import com.wbdgj.utils.dialog.ConfirmDialog;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import jp.wasabeef.glide.transformations.BlurTransformation;
import retrofit2.Call;

public class BookingRoomActivity extends BaseActivity {
    private Context context = this;

    private String id;
    private String startDateStr;
    private String endDateStr;
    private String surplus;
    private String IS_HOUR;

    @BindView(R.id.room_window)
    TextView room_window;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.computer_number)
    TextView computer_number;
    @BindView(R.id.room_rate)
    TextView room_rate;
    @BindView(R.id.brekker)
    TextView brekker;
    @BindView(R.id.CHECKIN_DATETIME)
    TextView CHECKIN_DATETIME;
    @BindView(R.id.jsTxt)
    TextView jsTxt;
    @BindView(R.id.ROOM_ID)
    TextView ROOM_ID;

    @BindView(R.id.yyrTxt)
    EditText yyrTxt;
    @BindView(R.id.cardTxt)
    EditText cardTxt;
    @BindView(R.id.remarkTxt)
    EditText remarkTxt;
    @BindView(R.id.rzrqTxt)
    TextView rzrqTxt;
    @BindView(R.id.tsTxt)
    TextView tsTxt;
    @BindView(R.id.ldrqTxt)
    TextView ldrqTxt;
    @BindView(R.id.sjhmTxt)
    EditText sjhmTxt;

    @BindView(R.id.room_rate_old)
    TextView room_rate_old;
    @BindView(R.id.phoneNum)
    TextView phoneNum;

    private Calendar calendar;
    private String roomID;
    private String room_hour;
    private String checkout_time1;
    private String phoneTxt;

    private Double roomApp;
    private Double discount_amount;

    @Override
    protected int getLayoutResId() {
        return R.layout.ui_booking_room;
    }

    @Override
    protected void initView() {
        calendar = Calendar.getInstance();
        id = getIntent().getStringExtra("id");

        surplus = getIntent().getStringExtra("surplus");
        IS_HOUR = getIntent().getStringExtra("IS_HOUR");

        if(IS_HOUR.equals("1")){
            findViewById(R.id.isHour01).setVisibility(View.GONE);
            findViewById(R.id.isHour02).setVisibility(View.GONE);
            findViewById(R.id.isHour03).setVisibility(View.GONE);
            findViewById(R.id.isHour04).setVisibility(View.GONE);
        }

        if(surplus.equals("0")){
            fast_reserve_date(id);
        }else{
            startDateStr = getIntent().getStringExtra("startDateStr");
            endDateStr = getIntent().getStringExtra("endDateStr");
            rzrqTxt.setText(startDateStr);
            ldrqTxt.setText(endDateStr);
            try {
                tsTxt.setText(ContextUtils.daysBetween(startDateStr, endDateStr)+"");
            } catch (ParseException e) {
                e.printStackTrace();
            }
            getMbUserInfo();
            room_price_old(id);
        }
        hotel_info();
    }

    private void fast_reserve_date(final String id) {
        Call<ResultObjectModel> call01 = HttpAdapter.getSerives().fast_reserve_date(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), id);
        call01.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")) {
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    final ConfirmDialog confirmDialog = new ConfirmDialog(context, "已为您自动切换入住日期："+linkedTreeMap.get("beg_date")+",请注意修改！", 1);
                    confirmDialog.show();
                    confirmDialog.setCanceledOnTouchOutside(false);
                    confirmDialog.setClicklistener(new ConfirmDialog.ClickListenerInterface() {
                        @Override
                        public void doConfirm() {
                            confirmDialog.dismiss();
                        }

                        @Override
                        public void doCancel() {
                            confirmDialog.dismiss();
                        }
                    });
                    startDateStr = linkedTreeMap.get("beg_date")+"";
                    endDateStr = linkedTreeMap.get("end_date")+"";
                    rzrqTxt.setText(startDateStr);
                    ldrqTxt.setText(endDateStr);
                    getMbUserInfo();
                    room_price_old(id);
                }else{
                    final ConfirmDialog confirmDialog = new ConfirmDialog(context,
                            userModelBaseResultModel.getResultMsg(), 1);
                    confirmDialog.show();
                    confirmDialog.setCanceledOnTouchOutside(false);
                    confirmDialog.setClicklistener(new ConfirmDialog.ClickListenerInterface() {
                        @Override
                        public void doConfirm() {
                            confirmDialog.dismiss();
                            finish();
                        }

                        @Override
                        public void doCancel() {
                            confirmDialog.dismiss();
                        }
                    });
                }
            }
        });
    }

    private void room_type_info(String ID_CARD) {
        Call<ResultObjectModel> call01 = HttpAdapter.getSerives().room_type_info(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), id, ID_CARD);
        call01.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")) {
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();

                    if(decimalFormat.format(linkedTreeMap.get("room_window")).equals("1")){
                        room_window.setText("有窗");
                    }else{
                        room_window.setText("无窗");
                    }
                    name.setText(linkedTreeMap.get("name")+"");
                    computer_number.setText( decimalFormat.format(linkedTreeMap.get("computer_number"))+"台电脑");


                    if(decimalFormat.format(linkedTreeMap.get("brekker")).equals("1")){
                        brekker.setText("含早餐");
                    }else{
                        brekker.setText("无早餐");
                    }

                }
            }
        });
    }

    @OnClick({R.id.rzfjLay, R.id.rzsjLay, R.id.rzrqLay, R.id.ldrqLay, R.id.jian, R.id.jia, R.id.ljyd, R.id.fjxxLay, R.id.call, R.id.callImg})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.callImg:
                if(TextUtils.isEmpty(phoneTxt)){
                    ToastUtils.toastShort("门店暂未设置联系方式！");
                }else{
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        if (ContextCompat.checkSelfPermission(context,
                                Manifest.permission.CALL_PHONE)
                                != PackageManager.PERMISSION_GRANTED) {
                            ActivityCompat.requestPermissions(getParent(), new String[]{Manifest.permission.CALL_PHONE}, 10);
                        }else{
                            Intent intent =new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneTxt));
                            startActivity(intent);
                        }
                    }else{
                        Intent intent =new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phoneTxt));
                        startActivity(intent);
                    }
                }
                break;
            case R.id.call:
                if(TextUtils.isEmpty(phoneTxt)){
                    ToastUtils.toastShort("门店暂未设置联系方式！");
                }else{
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        if (ContextCompat.checkSelfPermission(context,
                                Manifest.permission.CALL_PHONE)
                                != PackageManager.PERMISSION_GRANTED) {
                            ActivityCompat.requestPermissions(getParent(), new String[]{Manifest.permission.CALL_PHONE}, 10);
                        }else{
                            Intent intent =new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneTxt));
                            startActivity(intent);
                        }
                    }else{
                        Intent intent =new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phoneTxt));
                        startActivity(intent);
                    }
                }
                break;
            case R.id.fjxxLay:
                startActivity(new Intent(context, BookingRoomInfoActivity.class).putExtra("id", id)
                        .putExtra("IS_HOUR", IS_HOUR)
                        .putExtra("surplus", surplus)
                        .putExtra("startDateStr", rzrqTxt.getText().toString())
                        .putExtra("endDateStr", ldrqTxt.getText().toString()));
                break;
            case R.id.rzrqLay:
                DatePickerDialog datePicker02=new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear,
                                          int dayOfMonth) {
                        // TODO Auto-generated method stub
                        rzrqTxt.setText(year+"-"+ isOne(monthOfYear+1)+"-"+ isOne(dayOfMonth)+"");
                        try {
                            ldrqTxt.setText(ContextUtils.daysAdd(rzrqTxt.getText().toString(), Integer.parseInt(tsTxt.getText().toString())));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        if(rzrqTxt.getText().toString().equals(startDateStr) && ldrqTxt.getText().toString().equals(endDateStr)){

                        }else{
                            ROOM_ID.setText("");
                            roomID = "";
                        }
                        room_price(cardTxt.getText().toString(), id);
                    }
                },  calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),  calendar.get(Calendar.DAY_OF_MONTH));
                datePicker02.show();
                break;
            case R.id.ldrqLay:
                DatePickerDialog datePicker01=new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year, int monthOfYear,
                                          int dayOfMonth) {
                        // TODO Auto-generated method stub
                        ldrqTxt.setText(year+"-"+ isOne(monthOfYear+1)+"-"+ isOne(dayOfMonth)+"");
                        try {
                            tsTxt.setText(ContextUtils.daysBetween(rzrqTxt.getText().toString() , ldrqTxt.getText().toString())+"");
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        if(rzrqTxt.getText().toString().equals(startDateStr) && ldrqTxt.getText().toString().equals(endDateStr)){

                        }else{
                            ROOM_ID.setText("");
                            roomID = "";
                        }
                        room_price(cardTxt.getText().toString(), id);
                    }
                },  calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),  calendar.get(Calendar.DAY_OF_MONTH));
                datePicker01.show();
                break;
            case R.id.jian:
                int num = Integer.parseInt(tsTxt.getText().toString());
                if(num == 1){
                    num = 1;
                }else{
                    num -- ;
                }
                try {
                    ldrqTxt.setText(ContextUtils.daysAdd(rzrqTxt.getText().toString(), num));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                if(rzrqTxt.getText().toString().equals(startDateStr) && ldrqTxt.getText().toString().equals(endDateStr)){

                }else{
                    ROOM_ID.setText("");
                    roomID = "";
                }
                tsTxt.setText(num+"");
                room_price(cardTxt.getText().toString(), id);
                break;
            case R.id.jia:
                int numJ = Integer.parseInt(tsTxt.getText().toString());
                numJ ++ ;
                try {
                    ldrqTxt.setText(ContextUtils.daysAdd(rzrqTxt.getText().toString(), numJ));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                if(rzrqTxt.getText().toString().equals(startDateStr) && ldrqTxt.getText().toString().equals(endDateStr)){

                }else{
                    ROOM_ID.setText("");
                    roomID = "";
                }
                tsTxt.setText(numJ+"");
                room_price(cardTxt.getText().toString(), id);
                break;
            case R.id.rzfjLay:
                startActivityForResult(new Intent(context, ChoiceRoomDialogActivity.class)
                        .putExtra("CHECKIN_DATE", rzrqTxt.getText().toString())
                        .putExtra("CHECKOUT_DATE", ldrqTxt.getText().toString())
                        .putExtra("ROOM_TYPE_ID", id)
                        .putExtra("roomID", roomID)
                        .putExtra("roomIdNum", ROOM_ID.getText().toString())
                        .putExtra("IS_HOUR", IS_HOUR), 1);
                break;
            case R.id.rzsjLay:
                TimePickerDialog time2=new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {

                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                        // TODO Auto-generated method stub
                        CHECKIN_DATETIME.setText(isOne(hourOfDay) + ":" + isOne(minute));
                    }
                }, Integer.parseInt(checkout_time1.substring(0,2)), Integer.parseInt(checkout_time1.substring(3)), true);
                time2.show();
                break;
            case R.id.ljyd:
                if(TextUtils.isEmpty(CHECKIN_DATETIME.getText().toString())){
                    ToastUtils.toastShort("请选择到店时间");
                    return;
                }
                if(TextUtils.isEmpty(yyrTxt.getText().toString())){
                    ToastUtils.toastShort("请输入姓名");
                    return;
                }
                if(TextUtils.isEmpty(cardTxt.getText().toString())){
                    ToastUtils.toastShort("请输入身份证号码");
                    return;
                }
                if(TextUtils.isEmpty(sjhmTxt.getText().toString())){
                    ToastUtils.toastShort("请输入手机号码");
                    return;
                }
                if(TextUtils.isEmpty(roomID)){
                    ToastUtils.toastShort("请选择房间");
                    return;
                }
                room_reserve();
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == 1 && resultCode == 2){
            Bundle b = data.getExtras(); // 拿到B中存储的数据
            ROOM_ID.setText(b.getString("roomIdNum"));
            roomID = b.getString("roomId");
        }
    }

    private String isOne(int num){
        if (num<10){
            return "0"+num;
        }else{
            return num+"";
        }
    }

    private void getMbUserInfo() {
        Call<ResultObjectModel> call = HttpAdapter.getSerives().getMbUserInfo(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.TOKEN));
        call.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    yyrTxt.setText(linkedTreeMap.get("NAME")+"");
                    room_type_info(""+linkedTreeMap.get("ID_CARD"));
                    cardTxt.setText(""+linkedTreeMap.get("ID_CARD"));
                    sjhmTxt.setText(linkedTreeMap.get("PHONE")+"");
                    room_price(cardTxt.getText().toString(), id);
                }else if (userModelBaseResultModel.getResultCode().equals("1111")){
                    ToastUtils.toastShort("账号没有登录或在其它地方登录");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.TOKEN, "");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.IS_AUTO_LOGIN, "2");
                    PushManager.getInstance().unBindAlias(context, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.LOGIN_PHONE), false, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.CID));
                    Intent intent = new Intent(context, LoginActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }else{
                    ToastUtils.toastShort(userModelBaseResultModel.getResultMsg());
                }
            }
        });
    }

    private void room_price(String ID_CARD, String ROOM_TYPE_ID) {
        Call<ResultObjectModel> call = HttpAdapter.getSerives().room_price(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), ID_CARD, ROOM_TYPE_ID, rzrqTxt.getText().toString());
        call.enqueue(new OnNoResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    if(IS_HOUR.equals("0")){
                        if(decimalFormat.format(linkedTreeMap.get("room_app")).equals("0")){
                            roomApp = Double.parseDouble(decimalFormat.format(linkedTreeMap.get("room_rate")));
                        }else{
                            roomApp = Double.parseDouble(decimalFormat.format(linkedTreeMap.get("room_app")));
                        }
                        discount_amount = Double.parseDouble(decimalFormat.format(linkedTreeMap.get("discount_amount")));
                        room_rate.setText( (roomApp-discount_amount + roomApp* (Double.parseDouble(tsTxt.getText().toString()) -1))+"");
                    }else{
                        room_rate.setText(linkedTreeMap.get("hour_price")+"");
                    }
                }else if (userModelBaseResultModel.getResultCode().equals("1111")){
                    ToastUtils.toastShort("账号没有登录或在其它地方登录");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.TOKEN, "");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.IS_AUTO_LOGIN, "2");
                    PushManager.getInstance().unBindAlias(context, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.LOGIN_PHONE), false, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.CID));
                    Intent intent = new Intent(context, LoginActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
            }
        });
    }

    private void room_price_old(String ROOM_TYPE_ID) {
        Call<ResultObjectModel> call = HttpAdapter.getSerives().room_price(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), "0", ROOM_TYPE_ID, rzrqTxt.getText().toString());
        call.enqueue(new OnNoResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    if(IS_HOUR.equals("0")){
                        if(decimalFormat.format(linkedTreeMap.get("room_app")).equals("0")){
                            room_rate_old.setText("￥"+linkedTreeMap.get("room_rate")+"");
                        }else{
                            room_rate_old.setText("￥"+linkedTreeMap.get("room_app")+"");
                        }
                    }else{
                        room_rate_old.setText("￥"+linkedTreeMap.get("hour_price")+"");
                    }
                    room_rate_old.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
                }else if (userModelBaseResultModel.getResultCode().equals("1111")){
                    ToastUtils.toastShort("账号没有登录或在其它地方登录");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.TOKEN, "");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.IS_AUTO_LOGIN, "2");
                    PushManager.getInstance().unBindAlias(context, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.LOGIN_PHONE), false, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.CID));
                    Intent intent = new Intent(context, LoginActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }
            }
        });
    }

    private void room_reserve() {
        Call<ResultObjectModel> call;
        if(IS_HOUR.equals("0")){
            call = HttpAdapter.getSerives().room_reserve(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), roomID, yyrTxt.getText().toString(),
                    sjhmTxt.getText().toString(), cardTxt.getText().toString(), IS_HOUR, rzrqTxt.getText().toString()+" "+CHECKIN_DATETIME.getText().toString(), ldrqTxt.getText().toString()+" "+checkout_time1, "", room_rate.getText().toString(), remarkTxt.getText().toString());
        }else{
            call = HttpAdapter.getSerives().room_reserve(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID), roomID, yyrTxt.getText().toString(),
                    sjhmTxt.getText().toString(), cardTxt.getText().toString(), IS_HOUR, rzrqTxt.getText().toString()+" "+CHECKIN_DATETIME.getText().toString(), ContextUtils.addDateMinut(rzrqTxt.getText().toString()+" "+CHECKIN_DATETIME.getText().toString(), Integer.parseInt(room_hour)), room_hour, room_rate.getText().toString(), remarkTxt.getText().toString());
        }

        call.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    final ConfirmDialog confirmDialog = new ConfirmDialog(context, userModelBaseResultModel.getResultMsg(), 8);
                    confirmDialog.show();
                    confirmDialog.setCanceledOnTouchOutside(false);
                    confirmDialog.setClicklistener(new ConfirmDialog.ClickListenerInterface() {
                        @Override
                        public void doConfirm() {
                            confirmDialog.dismiss();
                            finish();
                        }

                        @Override
                        public void doCancel() {
                            confirmDialog.dismiss();
                            finish();
                        }
                    });

                }else if (userModelBaseResultModel.getResultCode().equals("1111")){
                    ToastUtils.toastShort("账号没有登录或在其它地方登录");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.TOKEN, "");
                    BaseApplication.getInstance().getSpUtil().putString(SpKeyUtils.IS_AUTO_LOGIN, "2");
                    PushManager.getInstance().unBindAlias(context, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.LOGIN_PHONE), false, BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.CID));
                    Intent intent = new Intent(context, LoginActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                }else{
                    ToastUtils.toastShort(userModelBaseResultModel.getResultMsg());
                }
            }
        });
    }

    private void hotel_info() {
        Call<ResultObjectModel> call01 = HttpAdapter.getSerives().hotel_info(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID));
        call01.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    LinkedTreeMap cfg_hotel = (LinkedTreeMap) linkedTreeMap.get("cfg_hotel");
                    room_hour = decimalFormat.format(cfg_hotel.get("room_hour"));
                    checkout_time1 = cfg_hotel.get("checkout_time1")+"";

                    if (linkedTreeMap.containsKey("branch_phone")){
                        phoneTxt = linkedTreeMap.get("branch_phone") +"";
                        phoneNum.setText(linkedTreeMap.get("branch_phone")+"");
                    }
                }
            }
        });
    }
}
